package com.jiyang.jyandroid.test03;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.TextView;

import com.jiyang.jyandroid.BaseActivity;
import com.jiyang.jyandroid.R;

/**
 * Created by jy on 2016/11/4.
 * 用第二个界面让用户选择信息
 */

public class Three_2Activity extends BaseActivity {
    private TextView tv;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_test03_1);
        findViewById(R.id.btn).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(Three_2Activity.this, Test03_1_aActivity.class);
                startActivityForResult(intent, 1);
            }
        });
        tv = (TextView) findViewById(R.id.tv);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (resultCode == 1) {
            String subject = "你选了[" + data.getStringExtra("subject") + "]哟!";
            tv.setText(subject);
        }
    }
}
